/**
 * @param {number[]} numbers
 * @param {number} target
 * @return {number[]}
 */
var twoSum = function (numbers, target) {
    let l = 0
    let len = numbers.length
    let r = len - 1
    let sum
    while (l <= r) {
        sum = numbers[l] + numbers[r]
        if (sum === target) {
            return [l + 1, r + 1]
        } else if (sum < target) {
            l++
        } else {
            r--
        }
    }
    return []
};


let numbers = [2, 7, 11, 15]
let target = 9

console.log(twoSum(numbers, target))

//================v1要点总结===============
/**
 * 1. 因为有序，且只有唯一解，采用双指针，左右向中间移动查找，可行
 */
